package com.wuxf.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wuxf.entity.ReceivePhone;
import com.wuxf.mapper.custom.ReceiveMapper;
import com.wuxf.util.DateUtils;

@Service
@SuppressWarnings({"rawtypes","unchecked"})
public class ReceiveService {
	@Autowired
	private ReceiveMapper receiveMapper;
	
	public List<ReceivePhone> findByMap(Map paraMap){
		return receiveMapper.findByMap(paraMap);
	}
	
	public List<ReceivePhone> findByUserId(int userId){
		Map paraMap = new HashMap();
		paraMap.put("userId", userId);
		
		return receiveMapper.findByMap(paraMap);
	}
	
	public PageInfo<List<ReceivePhone>> findByUserIdAndPage(int userId,PageInfo pageInfo){
		Map paraMap = new HashMap();
		paraMap.put("userId", userId);
		PageHelper.startPage(pageInfo.getPageNum(), pageInfo.getPageSize());
		return new PageInfo(receiveMapper.findByMap(paraMap));
	}
	
	public ReceivePhone saveReceivePhone(ReceivePhone receivePhone) {
		receivePhone.setCreateTime(DateUtils.getNowDate());
		receivePhone.setState("1");
		receiveMapper.saveReceivePhone(receivePhone);
		return receivePhone;
	}

	//删除跟车人
	public void deleteReceivePhone(int receiveId) {
		receiveMapper.deleteReceivePhone(receiveId);
	}
}
